#define MENU_SCROLL_STEP1 8
#define MENU_SCROLL_STEP2 15
-#define MENU_SCROLL_ARROW_HEIGHT 16
#define MENU_SCROLL_FAST_ZONE 8
#define MENU_SCROLL_TIMEOUT1 50
#define MENU_SCROLL_TIMEOUT2 20
GList *children;
guint vertical_padding;
guint horizontal_padding;
+ guint scroll_arrow_height;
g_return_if_fail (GTK_IS_MENU (widget));
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
+ "scroll-arrow-vlength", &scroll_arrow_height,
NULL);
attributes.x = border_width + widget->style->xthickness + horizontal_padding;
if (menu->upper_arrow_visible)
{
- attributes.y += MENU_SCROLL_ARROW_HEIGHT;
- attributes.height -= MENU_SCROLL_ARROW_HEIGHT;
+ attributes.y += scroll_arrow_height;
+ attributes.height -= scroll_arrow_height;
}
if (menu->lower_arrow_visible)
- attributes.height -= MENU_SCROLL_ARROW_HEIGHT;
+ attributes.height -= scroll_arrow_height;
menu->view_window = gdk_window_new (widget->window, &attributes, attributes_mask);
gdk_window_set_user_data (menu->view_window, menu);
gint width, height;
guint vertical_padding;
guint horizontal_padding;
-
+ gint scroll_arrow_height;
+
g_return_if_fail (GTK_IS_MENU (widget));
g_return_if_fail (allocation != NULL);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
+ "scroll-arrow-vlength", &scroll_arrow_height,
NULL);
x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness + horizontal_padding;
if (menu->upper_arrow_visible && !menu->tearoff_active)
{
- y += MENU_SCROLL_ARROW_HEIGHT;
- height -= MENU_SCROLL_ARROW_HEIGHT;
+ y += scroll_arrow_height;
+ height -= scroll_arrow_height;
}
if (menu->lower_arrow_visible && !menu->tearoff_active)
- height -= MENU_SCROLL_ARROW_HEIGHT;
+ height -= scroll_arrow_height;
if (GTK_WIDGET_REALIZED (widget))
{
gint border_x, border_y;
guint vertical_padding;
guint horizontal_padding;
-
+ gint scroll_arrow_height;
+
g_return_if_fail (GTK_IS_MENU (widget));
menu = GTK_MENU (widget);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
- NULL);
+ "scroll-arrow-vlength", &scroll_arrow_height,
+ NULL);
border_x = GTK_CONTAINER (widget)->border_width + widget->style->xthickness + horizontal_padding;
border_y = GTK_CONTAINER (widget)->border_width + widget->style->ythickness + vertical_padding;
if (event->window == widget->window)
{
- gint arrow_space = MENU_SCROLL_ARROW_HEIGHT - 2 * widget->style->ythickness;
+ gint arrow_space = scroll_arrow_height - 2 * widget->style->ythickness;
gint arrow_size = 0.7 * arrow_space;
gtk_paint_box (widget->style,
border_x,
border_y,
width - 2 * border_x,
- MENU_SCROLL_ARROW_HEIGHT);
+ scroll_arrow_height);
gtk_paint_arrow (widget->style,
widget->window,
GTK_SHADOW_OUT,
NULL, widget, "menu",
border_x,
- height - border_y - MENU_SCROLL_ARROW_HEIGHT,
+ height - border_y - scroll_arrow_height,
width - 2*border_x,
- MENU_SCROLL_ARROW_HEIGHT);
+ scroll_arrow_height);
gtk_paint_arrow (widget->style,
widget->window,
GTK_ARROW_DOWN,
TRUE,
(width - arrow_size) / 2,
- height - border_y - MENU_SCROLL_ARROW_HEIGHT +
+ height - border_y - scroll_arrow_height +
widget->style->ythickness + (arrow_space - arrow_size)/2,
arrow_size, arrow_size);
}
gint offset;
gint view_width, view_height;
gboolean double_arrows;
-
+ gint scroll_arrow_height;
+
widget = GTK_WIDGET (menu);
offset = menu->scroll_offset + step;
+ gtk_widget_style_get (GTK_WIDGET (menu),
+ "scroll-arrow-vlength", &scroll_arrow_height,
+ NULL);
+
double_arrows = get_double_arrows (menu);
/* If we scroll upward and the non-visible top part
* screen space than just scrolling to the top.
*/
if (!double_arrows)
- if ((step < 0) && (offset < MENU_SCROLL_ARROW_HEIGHT))
+ if ((step < 0) && (offset < scroll_arrow_height))
offset = 0;
/* Don't scroll over the top if we weren't before: */
/* Don't scroll past the bottom if we weren't before: */
if (menu->scroll_offset > 0)
- view_height -= MENU_SCROLL_ARROW_HEIGHT;
+ view_height -= scroll_arrow_height;
/* When both arrows are always shown, reduce
* view height even more.
*/
if (double_arrows)
- view_height -= MENU_SCROLL_ARROW_HEIGHT;
+ view_height -= scroll_arrow_height;
if ((menu->scroll_offset + view_height <= widget->requisition.height) &&
(offset + view_height > widget->requisition.height))
gint win_x, win_y;
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (menu));
gboolean touchscreen_mode;
-
+ gint scroll_arrow_height;
+
priv = gtk_menu_get_private (menu);
menu_shell = GTK_MENU_SHELL (menu);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
+ "scroll-arrow-vlength", &scroll_arrow_height,
NULL);
border = GTK_CONTAINER (menu)->border_width +
rect.x = win_x;
rect.y = win_y;
rect.width = width;
- rect.height = MENU_SCROLL_ARROW_HEIGHT + border;
+ rect.height = scroll_arrow_height + border;
in_arrow = FALSE;
if (menu->upper_arrow_visible && !menu->tearoff_active &&
/* lower arrow handling */
rect.x = win_x;
- rect.y = win_y + height - border - MENU_SCROLL_ARROW_HEIGHT;
+ rect.y = win_y + height - border - scroll_arrow_height;
rect.width = width;
- rect.height = MENU_SCROLL_ARROW_HEIGHT + border;
+ rect.height = scroll_arrow_height + border;
in_arrow = FALSE;
if (menu->lower_arrow_visible && !menu->tearoff_active &&
GdkScreen *screen;
GdkScreen *pointer_screen;
GdkRectangle monitor;
-
+ gint scroll_arrow_height;
+
g_return_if_fail (GTK_IS_MENU (menu));
widget = GTK_WIDGET (menu);
gdk_display_get_pointer (gdk_screen_get_display (screen),
&pointer_screen, &x, &y, NULL);
+ gtk_widget_style_get (GTK_WIDGET (menu),
+ "scroll-arrow-vlength", &scroll_arrow_height,
+ NULL);
+
/* We need the requisition to figure out the right place to
* popup the menu. In fact, we always need to ask here, since
* if a size_request was queued while we weren't popped up,
}
if (scroll_offset > 0)
- scroll_offset += MENU_SCROLL_ARROW_HEIGHT;
+ scroll_offset += scroll_arrow_height;
gtk_window_move (GTK_WINDOW (GTK_MENU_SHELL (menu)->active ? menu->toplevel : menu->tearoff_window),
x, y);
guint vertical_padding;
guint horizontal_padding;
gboolean double_arrows;
-
+ gint scroll_arrow_height;
+
widget = GTK_WIDGET (menu);
if (menu->tearoff_active &&
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
+ "scroll-arrow-vlength", &scroll_arrow_height,
NULL);
double_arrows = get_double_arrows (menu);
if (!menu->upper_arrow_visible || !menu->lower_arrow_visible)
gtk_widget_queue_draw (GTK_WIDGET (menu));
- view_height -= 2 * MENU_SCROLL_ARROW_HEIGHT;
- y += MENU_SCROLL_ARROW_HEIGHT;
+ view_height -= 2 * scroll_arrow_height;
+ y += scroll_arrow_height;
menu->upper_arrow_visible = menu->lower_arrow_visible = TRUE;
menu->upper_arrow_visible = offset > 0;
if (menu->upper_arrow_visible)
- view_height -= MENU_SCROLL_ARROW_HEIGHT;
+ view_height -= scroll_arrow_height;
if ((last_visible != menu->upper_arrow_visible) &&
!menu->upper_arrow_visible)
menu->lower_arrow_visible = offset < menu_height - view_height;
if (menu->lower_arrow_visible)
- view_height -= MENU_SCROLL_ARROW_HEIGHT;
+ view_height -= scroll_arrow_height;
if ((last_visible != menu->lower_arrow_visible) &&
!menu->lower_arrow_visible)
}
if (menu->upper_arrow_visible)
- y += MENU_SCROLL_ARROW_HEIGHT;
+ y += scroll_arrow_height;
}
/* Scroll the menu: */
{
guint vertical_padding;
gboolean double_arrows;
-
+ gint scroll_arrow_height;
+
y = menu->scroll_offset;
gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
+ "scroll-arrow-vlength", &scroll_arrow_height,
NULL);
double_arrows = get_double_arrows (menu);
{
arrow_height = 0;
if (menu->upper_arrow_visible && !menu->tearoff_active)
- arrow_height += MENU_SCROLL_ARROW_HEIGHT;
+ arrow_height += scroll_arrow_height;
if (menu->lower_arrow_visible && !menu->tearoff_active)
- arrow_height += MENU_SCROLL_ARROW_HEIGHT;
+ arrow_height += scroll_arrow_height;
if (child_offset + child_height > y + height - arrow_height)
{
arrow_height = 0;
if ((!last_child && !menu->tearoff_active) || double_arrows)
- arrow_height += MENU_SCROLL_ARROW_HEIGHT;
+ arrow_height += scroll_arrow_height;
y = child_offset + child_height - height + arrow_height;
if (((y > 0) && !menu->tearoff_active) || double_arrows)
{
/* Need upper arrow */
- arrow_height += MENU_SCROLL_ARROW_HEIGHT;
+ arrow_height += scroll_arrow_height;
y = child_offset + child_height - height + arrow_height;
}
/* Ignore the enter event we might get if the pointer is on the menu
{
GtkWidget *widget = GTK_WIDGET (menu);
GtkContainer *container = GTK_CONTAINER (menu);
+ gint scroll_arrow_height;
gint menu_height = (widget->allocation.height
- 2 * (container->border_width
+ widget->style->ythickness));
+ gtk_widget_style_get (GTK_WIDGET (menu),
+ "scroll-arrow-vlength", &scroll_arrow_height,
+ NULL);
+
if (menu->upper_arrow_visible && !menu->tearoff_active)
- menu_height -= MENU_SCROLL_ARROW_HEIGHT;
+ menu_height -= scroll_arrow_height;
if (menu->lower_arrow_visible && !menu->tearoff_active)
- menu_height -= MENU_SCROLL_ARROW_HEIGHT;
+ menu_height -= scroll_arrow_height;
return menu_height;
}
{
gint height;
GtkWidget *widget = GTK_WIDGET (menu);
+ gint scroll_arrow_height;
+ gtk_widget_style_get (GTK_WIDGET (menu),
+ "scroll-arrow-vlength", &scroll_arrow_height,
+ NULL);
+
height = widget->requisition.height;
height -= (GTK_CONTAINER (widget)->border_width + widget->style->ythickness) * 2;
if (menu->upper_arrow_visible && !menu->tearoff_active)
- height -= MENU_SCROLL_ARROW_HEIGHT;
+ height -= scroll_arrow_height;
if (menu->lower_arrow_visible && !menu->tearoff_active)
- height -= MENU_SCROLL_ARROW_HEIGHT;
+ height -= scroll_arrow_height;
return height;
}
gint page_size = get_visible_size (menu);
gint end_position = get_menu_height (menu);
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menu);
+ gint scroll_arrow_height;
+
+ gtk_widget_style_get (GTK_WIDGET (menu),
+ "scroll-arrow-vlength", &scroll_arrow_height,
+ NULL);
switch (type)
{
if (menu->scroll_offset != old_offset)
step = menu->scroll_offset - old_offset;
- step -= (new_upper_arrow_visible - old_upper_arrow_visible) * MENU_SCROLL_ARROW_HEIGHT;
+ step -= (new_upper_arrow_visible - old_upper_arrow_visible) * scroll_arrow_height;
new_child = child_at (menu, child_offset + step);
if (new_child)
#include "gtkalias.h"
#include "gtkdnd.h"
-#define ARROW_SIZE 12
-#define ARROW_SPACING 0
#define SCROLL_DELAY_FACTOR 5
#define SCROLL_THRESHOLD 12
#define DND_THRESHOLD_MULTIPLIER 4
1,
GTK_PARAM_READABLE));
+ /**
+ * GtkNotebook:arrow-spacing:
+ *
+ * The "arrow-size" property defines the spacing between the scroll
+ * arrows and the tabs.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("arrow-spacing",
+ _("Arrow spacing"),
+ _("Scroll arrow spacing"),
+ 0,
+ G_MAXINT,
+ 0,
+ GTK_PARAM_READABLE));
+
notebook_signals[SWITCH_PAGE] =
g_signal_new (I_("switch_page"),
G_TYPE_FROM_CLASS (gobject_class),
gint focus_width;
gint tab_overlap;
gint tab_curvature;
+ gint arrow_spacing;
+ gint scroll_arrow_hlength;
+ gint scroll_arrow_vlength;
gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
"tab-overlap", &tab_overlap,
"tab-curvature", &tab_curvature,
+ "arrow-spacing", &arrow_spacing,
+ "scroll-arrow-hlength", &scroll_arrow_hlength,
+ "scroll-arrow-vlength", &scroll_arrow_vlength,
NULL);
-
+
widget->requisition.width = 0;
widget->requisition.height = 0;
if (notebook->scrollable && vis_pages > 1 &&
widget->requisition.width < tab_width)
- tab_height = MAX (tab_height, ARROW_SIZE);
+ tab_height = MAX (tab_height, scroll_arrow_hlength);
padding = 2 * (tab_curvature + focus_width +
notebook->tab_hborder) - tab_overlap;
if (notebook->scrollable && vis_pages > 1 &&
widget->requisition.width < tab_width)
- tab_width = tab_max + 2 * (ARROW_SIZE + ARROW_SPACING);
+ tab_width = tab_max + 2 * (scroll_arrow_hlength + arrow_spacing);
if (notebook->homogeneous && !notebook->scrollable)
widget->requisition.width = MAX (widget->requisition.width,
if (notebook->scrollable && vis_pages > 1 &&
widget->requisition.height < tab_height)
- tab_width = MAX (tab_width, ARROW_SPACING + 2 * ARROW_SIZE);
+ tab_width = MAX (tab_width,
+ arrow_spacing + 2 * scroll_arrow_vlength);
padding = 2 * (tab_curvature + focus_width +
notebook->tab_vborder) - tab_overlap;
if (notebook->scrollable && vis_pages > 1 &&
widget->requisition.height < tab_height)
- tab_height = tab_max + ARROW_SIZE + ARROW_SPACING;
+ tab_height = tab_max + scroll_arrow_vlength + arrow_spacing;
widget->requisition.width += tab_width;
if (gtk_notebook_get_event_window_position (notebook, &event_window_pos))
{
- rectangle->width = ARROW_SIZE;
- rectangle->height = ARROW_SIZE;
+ gint scroll_arrow_hlength;
+ gint scroll_arrow_vlength;
+
+ gtk_widget_style_get (GTK_WIDGET (notebook),
+ "scroll-arrow-hlength", &scroll_arrow_hlength,
+ "scroll-arrow-vlength", &scroll_arrow_vlength,
+ NULL);
switch (notebook->tab_pos)
{
case GTK_POS_LEFT:
case GTK_POS_RIGHT:
+ rectangle->width = scroll_arrow_vlength;
+ rectangle->height = scroll_arrow_vlength;
+
if ((before && (notebook->has_before_previous != notebook->has_before_next)) ||
(!before && (notebook->has_after_previous != notebook->has_after_next)))
rectangle->x = event_window_pos.x + (event_window_pos.width - rectangle->width) / 2;
if (!before)
rectangle->y += event_window_pos.height - rectangle->height;
break;
+
case GTK_POS_TOP:
case GTK_POS_BOTTOM:
+ rectangle->width = scroll_arrow_hlength;
+ rectangle->height = scroll_arrow_hlength;
+
if (before)
{
if (left || !notebook->has_before_previous)
if (GTK_WIDGET_DRAWABLE (notebook))
{
+ gint scroll_arrow_hlength;
+ gint scroll_arrow_vlength;
+ gint arrow_size;
+
+ gtk_widget_style_get (widget,
+ "scroll-arrow-hlength", &scroll_arrow_hlength,
+ "scroll-arrow-vlength", &scroll_arrow_vlength,
+ NULL);
+
if (notebook->in_child == nbarrow)
{
if (notebook->click_child == nbarrow)
if (notebook->tab_pos == GTK_POS_LEFT ||
notebook->tab_pos == GTK_POS_RIGHT)
- arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_UP : GTK_ARROW_DOWN);
+ {
+ arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_UP : GTK_ARROW_DOWN);
+ arrow_size = scroll_arrow_vlength;
+ }
else
- arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT);
+ {
+ arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT);
+ arrow_size = scroll_arrow_hlength;
+ }
gtk_paint_arrow (widget->style, widget->window, state_type,
shadow_type, NULL, widget, "notebook",
arrow, TRUE, arrow_rect.x, arrow_rect.y,
- ARROW_SIZE, ARROW_SIZE);
+ arrow_size, arrow_size);
}
}
GList *children;
gint tab_pos = get_effective_tab_pos (notebook);
gint tab_overlap;
+ gint arrow_spacing;
+ gint scroll_arrow_hlength;
+ gint scroll_arrow_vlength;
widget = GTK_WIDGET (notebook);
priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
children = notebook->children;
+ gtk_widget_style_get (GTK_WIDGET (notebook),
+ "arrow-spacing", &arrow_spacing,
+ "scroll-arrow-hlength", &scroll_arrow_hlength,
+ "scroll-arrow-vlength", &scroll_arrow_vlength,
+ NULL);
+
switch (tab_pos)
{
case GTK_POS_TOP:
if (notebook->has_after_previous)
{
- *tab_space -= ARROW_SPACING + ARROW_SIZE;
- *max -= ARROW_SPACING + ARROW_SIZE;
+ *tab_space -= arrow_spacing + scroll_arrow_hlength;
+ *max -= arrow_spacing + scroll_arrow_hlength;
}
if (notebook->has_after_next)
{
- *tab_space -= ARROW_SPACING + ARROW_SIZE;
- *max -= ARROW_SPACING + ARROW_SIZE;
+ *tab_space -= arrow_spacing + scroll_arrow_hlength;
+ *max -= arrow_spacing + scroll_arrow_hlength;
}
if (notebook->has_before_previous)
{
- *tab_space -= ARROW_SPACING + ARROW_SIZE;
- *min += ARROW_SPACING + ARROW_SIZE;
+ *tab_space -= arrow_spacing + scroll_arrow_hlength;
+ *min += arrow_spacing + scroll_arrow_hlength;
}
if (notebook->has_before_next)
{
- *tab_space -= ARROW_SPACING + ARROW_SIZE;
- *min += ARROW_SPACING + ARROW_SIZE;
+ *tab_space -= arrow_spacing + scroll_arrow_hlength;
+ *min += arrow_spacing + scroll_arrow_hlength;
}
}
break;
if (notebook->has_after_previous || notebook->has_after_next)
{
- *tab_space -= ARROW_SPACING + ARROW_SIZE;
- *max -= ARROW_SPACING + ARROW_SIZE;
+ *tab_space -= arrow_spacing + scroll_arrow_vlength;
+ *max -= arrow_spacing + scroll_arrow_vlength;
}
if (notebook->has_before_previous || notebook->has_before_next)
{
- *tab_space -= ARROW_SPACING + ARROW_SIZE;
- *min += ARROW_SPACING + ARROW_SIZE;
+ *tab_space -= arrow_spacing + scroll_arrow_vlength;
+ *min += arrow_spacing + scroll_arrow_vlength;
}
}
break;